import {warehouseManagement} from '@/api/equip/warehouseManagement.js'

export const FormEvent = {
  form: {
    id: '',
    kfName: "",//机房名称
    ywdwmc: "",//运维单位名称
    ywdwbm: "",//运维单位编码
    address: "",//地址
    createPeople: "",//创建人
    createTime: "",//创建时间       //产业单位编码
    status: "0",
    isDel: "0"
  },
  rules: {
    kfName: [
      {required: true, message: '机房名称 不能为空', trigger: 'blur'},
    ],
    ywdwbm: [
      {required: true, message: '管理单位 不能为空', trigger: 'blur'},
    ]
  },
  type: '', ////insert-update//
  initFormData(formData) { 		//初始化表单信�?//
    FormEvent.type = formData.type;
    if (FormEvent.type === 'insert') {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = undefined;
      }
      this.form.status = '0'
      this.form.isDel = '0'
    } else {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = formData.data[key];
      }
    }
  },
  saveFormData() {
    if (FormEvent.type === 'insert') {
      //执行新增操作//
      debugger
      const insertData = [FormEvent.form];
      return warehouseManagement.insert(insertData);
    } else {
      //执行更新操作//
      const updateData = [FormEvent.form];
      return warehouseManagement.update(updateData);
    }
  }
}


